package com.googlecode.yoohoo.xmppcore.parsing;

import com.googlecode.yoohoo.xmppcore.protocol.parsing.IXmppParserFactory;
import com.googlecode.yoohoo.xmppcore.protocol.parsing.ProtocolRelation;
import com.googlecode.yoohoo.xmppcore.protocol.parsing.ProtocolRelations;

public class ParserContribution {
	private IXmppParserFactory<?> parserFactory;
	private ProtocolRelations relations;
	
	public ParserContribution(IXmppParserFactory<?> parserFactory) {
		this(parserFactory, (ProtocolRelation)null);
	}
	
	public ParserContribution(IXmppParserFactory<?> parserFactory, ProtocolRelation relation) {
		this(parserFactory, createRelations(relation));
	}
	
	private static ProtocolRelations createRelations(ProtocolRelation relation) {
		if (relation == null)
			return null;
		
		ProtocolRelations relations = new ProtocolRelations();
		relations.addProtocolRelation(relation);
		
		return relations;
	}

	public ParserContribution(IXmppParserFactory<?> parserFactory, ProtocolRelations relations) {
		this.parserFactory = parserFactory;
		this.relations = relations;
	}
	
	public IXmppParserFactory<?> getParserFactory() {
		return parserFactory;
	}

	public ProtocolRelations getRelations() {
		return relations;
	}

	public void setParserFactory(IXmppParserFactory<?> parserFactory) {
		this.parserFactory = parserFactory;
	}

	public void setRelations(ProtocolRelations relations) {
		this.relations = relations;
	}
}
